package com.tamo.ppresta.json;

import com.tamo.ppresta.util.AESUtils;

import java.util.Map;

/**
 * @author yeyang
 * @name ppresta
 * @class name：com.tamo.ppresta.json
 * @class describe
 * @time 2022/12/23 20:54
 * @change
 * @chang time
 * @class describe
 */
public class ObjectToJsonUtil {
    public static String getJson(Map<String, Object> map) {
        StringBuffer sb = new StringBuffer();
        sb.append("{");
        if (null != map) {
            for (String key : map.keySet()) {
                sb.append("\"" + key + "\":");
                sb.append("\"" + map.get(key) + "\",");
            }
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append("}");
        return sb.toString();
    }

    public static String getNewJson(Map<String, Object> map) {
        StringBuffer sb = new StringBuffer();
        sb.append("{");
        if (null != map) {
            for (String key : map.keySet()) {
                sb.append("\"" + AESUtils.getRandomStr(3) + key + AESUtils.getRandomStr(2) + "\":");
                sb.append("\"" + map.get(key) + "\",");
            }
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append("}");
        return sb.toString();
    }
} 